package ioc14;

import org.springframework.beans.factory.FactoryBean;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Author:shixiaojun@itany.com
 * Date:2022/5/17 11:22
 * Version:1.0-SNAPSHOT
 * Description:
 */
public class DateFactoryBean implements FactoryBean {

    private String year;
    private String month;
    private String day;

    public void setYear(String year) {
        this.year = year;
    }

    public void setMonth(String month) {
        this.month = month;
    }

    public void setDay(String day) {
        this.day = day;
    }

    @Override
    public Object getObject() throws Exception {
        Date date = new SimpleDateFormat("yyyy-MM-dd").parse(year+"-"+month+"-"+day);
        return date;
    }

    @Override
    public Class<?> getObjectType() {
        return Date.class;
    }
}
